<%@ page import="com.ld.businesscard_manage.service.UserService" %>
<%@ page import="com.ld.businesscard_manage.bean.User" %>
<%@ page import="com.ld.businesscard_manage.service.impl.UserServiceImpl" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-01
  Time: 20:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改用户信息</title>
    <style>
        .container {
            background-color: #fff;
            border-radius: 10px;
            box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
            position: relative;
            overflow: hidden;
            width: 768px;
            max-width: 100%;
            min-height: 480px;
            margin:0 auto;
        }
        .container div{
            margin-top: 20px;
            margin-left: 40%;
        }

        input {
            background-color: #eee;
            border: none;
            padding: 12px 15px;
            margin: 8px 10px;
        }
    </style>
</head>
<body>
    <%!
        private UserService userService = new UserServiceImpl();
    %>
<%
    User user = userService.getUserById(Integer.parseInt(request.getParameter("id")));
	session.setAttribute("currentUser",user);

%>
<form action="/home/changeUserOutcome.jsp" method="post" class="container">
    <div>id:<input name="id" disabled placeholder="<%=user.getId()%>" value="<%=user.getId()%>"></div>
    <div>用户名:<input name="username" placeholder="<%=user.getUsername()%>" ></div>
    <div>密码:<input name="password" id="u_pwd" type="password"></div>
    <div>确认密码:<input name="repassword" id="u_rpwd" type="password"></div>
    <div>权限:<input name="status" placeholder="<%=user.getStatus()%>" disabled></div>
    <div style="padding-left: 30px"><input type="submit" value="修改" id="change"></div>
</form>
</body>
<script>
    let u_pwd = document.getElementById("u_pwd");
    let u_rpwd = document.getElementById("u_rpwd");
    let change = document.getElementById("change");
    change.addEventListener("click",(e)=>{
        if(u_pwd.value == "" || u_pwd.value == null){
            alert("请输入修改后的密码!")
            e.preventDefault();
        }else if(u_rpwd.value == "" || u_rpwd.value == null){
            alert("请输入确认密码!");
            e.preventDefault();
        }
        else if(u_rpwd.value !== u_pwd.value){
            alert("两次输入密码不一致!")
            e.preventDefault();
        }
    })
</script>
</html>
